package offer;

import java.util.ArrayList;
import java.util.List;

public class offer57second {
    public static int[][] findContinuousSequence(int target) {
        List<Integer> track = new ArrayList<>();
        List<List<Integer>> res =new ArrayList<>();

        for (int i = 1; i <target/2 ; i++) {
            int sum =0;
            for (int j = i; j < target; j++) {
                sum =sum+j;
                if(sum>target)break;
                if(sum==target)
                {
                    for (int k = i; k <=j ; k++) {
                        track.add(k);
                    }
                    res.add(new ArrayList<>(track));
                    track.clear();
                }
            }

        }
        int[][] ans = new int[res.size()][];
        for(int i = 0; i <ans.length; i++){
            ans[i] = new int[res.get(i).size()];
            for(int j = 0; j < ans[i].length; j++){
                ans[i][j] = res.get(i).get(j);
            }
        }

        return ans;
    }

    public static void main(String[] args) {
        findContinuousSequence(9);
    }
}



